package com.example.texted.countdownlatch;

import com.example.texted.decoratorpattern.Feature;

import java.util.ArrayList;
import java.util.concurrent.*;

public class Do {
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        int num = 10;
        CountDownLatch begin = new CountDownLatch(1);
        CountDownLatch end = new CountDownLatch(num);
        ExecutorService es = Executors.newFixedThreadPool(num);
        ArrayList<Future<Integer>> futures = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            futures.add(es.submit(new Runner(begin, end)));
        }
        long now = System.currentTimeMillis();
        begin.countDown();
        end.await();
        long n = System.currentTimeMillis() - now;
//        System.out.println(n);
        int count = 0;
        for (Future<Integer> future : futures) {
            System.out.println(future.get());
        }

        es.shutdown();
    }
}
